home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / io / CharToByteSingleByte.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  1.6 KB  |  124 lines

  1. package sun.io;
  2.  
  3. public abstract class CharToByteSingleByte extends CharToByteConverter {
  4.    protected short[] index1;
  5.    protected String index2;
  6.    protected int mask1;
  7.    protected int mask2;
  8.    protected int shift;
  9.    private char highHalfZoneCode;
  10.  
  11.    public short[] getIndex1() {
  12.       return this.index1;
  13.    }
  14.  
  15.    public String getIndex2() {
  16.       return this.index2;
  17.    }
  18.  
  19.    public int flush(byte[] var1, int var2, int var3) throws MalformedInputException {
  20.       if (this.highHalfZoneCode != 0) {
  21.          this.highHalfZoneCode = 0;
  22.          this.badInputLength = 0;
  23.          throw new MalformedInputException();
  24.       } else {
  25.          this.byteOff = this.charOff = 0;
  26.          return 0;
  27.       }
  28.    }
  29.  
  30.    public int convert(char[] var1, int var2, int var3, byte[] var4, int var5, int var6) throws MalformedInputException, UnknownCharacterException, ConversionBufferFullException {
  31.       byte[] var11 = new byte[1];
  32.       this.charOff = var2;
  33.       this.byteOff = var5;
  34.       if (this.highHalfZoneCode != 0) {
  35.          char var14 = this.highHalfZoneCode;
  36.          this.highHalfZoneCode = 0;
  37.          if (var1[var2] >= '\udc00' && var1[var2] <= '\udfff') {
  38.             this.badInputLength = 1;
  39.             throw new UnknownCharacterException();
  40.          } else {
  41.             this.badInputLength = 0;
  42.             throw new MalformedInputException();
  43.          }
  44.       } else {
  45.          while(this.charOff < var3) {
  46.             byte[] var8 = var11;
  47.             char var7 = var1[this.charOff];
  48.             int var10 = 1;
  49.             byte var9 = 1;
  50.             if (var7 >= '\ud800' && var7 <= '\udbff') {
  51.                if (this.charOff + 1 >= var3) {
  52.                   this.highHalfZoneCode = var7;
  53.                   break;
  54.                }
  55.  
  56.                var7 = var1[this.charOff + 1];
  57.                if (var7 < '\udc00' || var7 > '\udfff') {
  58.                   this.badInputLength = 1;
  59.                   throw new MalformedInputException();
  60.                }
  61.  
  62.                if (!this.subMode) {
  63.                   this.badInputLength = 2;
  64.                   throw new UnknownCharacterException();
  65.                }
  66.  
  67.                var8 = this.subBytes;
  68.                var10 = this.subBytes.length;
  69.                var9 = 2;
  70.             } else {
  71.                if (var7 >= '\udc00' && var7 <= '\udfff') {
  72.                   this.badInputLength = 1;
  73.                   throw new MalformedInputException();
  74.                }
  75.  
  76.                var11[0] = this.getNative(var7);
  77.                if (var11[0] == 0 && var1[this.charOff] != 0) {
  78.                   if (!this.subMode) {
  79.                      this.badInputLength = 1;
  80.                      throw new UnknownCharacterException();
  81.                   }
  82.  
  83.                   var8 = this.subBytes;
  84.                   var10 = this.subBytes.length;
  85.                }
  86.             }
  87.  
  88.             if (this.byteOff + var10 > var6) {
  89.                throw new ConversionBufferFullException();
  90.             }
  91.  
  92.             for(int var12 = 0; var12 < var10; ++var12) {
  93.                var4[this.byteOff++] = var8[var12];
  94.             }
  95.  
  96.             this.charOff += var9;
  97.          }
  98.  
  99.          return this.byteOff - var5;
  100.       }
  101.    }
  102.  
  103.    public int getMaxBytesPerChar() {
  104.       return 1;
  105.    }
  106.  
  107.    public byte getNative(char var1) {
  108.       return (byte)this.index2.charAt(this.index1[(var1 & this.mask1) >> this.shift] + (var1 & this.mask2));
  109.    }
  110.  
  111.    public void reset() {
  112.       this.byteOff = this.charOff = 0;
  113.       this.highHalfZoneCode = 0;
  114.    }
  115.  
  116.    public boolean canConvert(char var1) {
  117.       if (this.index2.charAt(this.index1[(var1 & this.mask1) >> this.shift] + (var1 & this.mask2)) != 0) {
  118.          return true;
  119.       } else {
  120.          return var1 == 0;
  121.       }
  122.    }
  123. }
  124.